package com.vhall.component.controller.livecolumn;

import com.vhall.component.entity.livecolumn.vo.LiveColumnInfoRequestVO;
import com.vhall.component.entity.livecolumn.vo.LiveColumnInfoResponseVO;
import com.vhall.component.plugin.common.annotation.TokenAuth;
import com.vhall.component.plugin.common.annotation.VssTokenAuth;
import com.vhall.component.service.livecolumn.LiveColumnService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 栏目服务(观看端)
 *
 * @author jingwen.li
 */
@RestController
@RequestMapping("/v4/live-column/")
public class LiveColumnController {

    @Resource
    private LiveColumnService liveColumnService;


    /**
     * 获取栏目信息
     *
     * @param vo 请求参数
     * @return
     */
    @TokenAuth(check = false)
    @PostMapping("/info")
    public LiveColumnInfoResponseVO info(LiveColumnInfoRequestVO vo) {
        return liveColumnService.info(vo);
    }
    /**
     * 获取栏目信息
     * 不处理指定的房间数据 只处理栏目相关所有房间的数据
     *
     * @param vo 请求参数
     * @return
     */
    @TokenAuth(check = false)
    @PostMapping("/info2")
    public LiveColumnInfoResponseVO info2(LiveColumnInfoRequestVO vo) {
        vo.setIlId(null);
        return liveColumnService.info(vo);
    }
    /**
     * 订阅栏目
     *
     * @param columnId
     * @return
     */
    @TokenAuth
    @PostMapping("/subscribe")
    public Boolean subscribe(@RequestParam("column_id") Integer columnId) {
        return liveColumnService.subscribe(columnId);
    }

    /**
     * 取消订阅
     *
     * @param columnId
     * @return
     */
    @TokenAuth
    @PostMapping("/unsubscribe")
    public Boolean unsubscribe(@RequestParam("column_id") Integer columnId) {
        return liveColumnService.unsubscribe(columnId);
    }

    /**
     * 订阅
     * @param columnId 栏目ID
     * @param flag true :订阅  false：取消订阅
     * @return
     */
    @TokenAuth
    @PostMapping("/sub")
    public Boolean sub(@RequestParam("column_id") Integer columnId,@RequestParam("flag") boolean flag) {
        if (flag){
            return liveColumnService.subscribe(columnId);
        }else {
            return liveColumnService.unsubscribe(columnId);
        }
    }

    /**
     * 是否订阅
     * @param columnId 栏目ID
     * @return boolean
     */
    @TokenAuth
    @PostMapping("/is-subscribe")
    public Boolean getSubInfo(@RequestParam("column_id") Integer columnId){
            return liveColumnService.isSub(columnId);
    }

}
